﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MatchCore;

public class BattleGameObjManager : MonoBehaviour
{
    public UIPlayerController[] uiplayers;

    public bool InitObjs()
    {
        var roomInfo = Model.Instance().roomModel.roomInfo;
        if(null == roomInfo || null == roomInfo.GameStartInfo)
        {
            Debug.LogError("BattleGameObjManager Start roomInfo is null!");
            return false;
        }

        if(roomInfo.GameStartInfo.Players.Count != uiplayers.Length)
        {
            Debug.LogError("roomInfo.GameStartInfo.Players.Count != uiplayers.Length!");
            return false;
        }

        var playerInfos = roomInfo.GameStartInfo.Players;
        for(int i = 0; i < playerInfos.Count; i++)
        {
            var uiPlayer = uiplayers[i];
            var player = uiPlayer.CreatePlayer(playerInfos[i]);
            LogicManager.Instance().AddPlayer(player);
        }

        return true;
    }
    
}
